<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>index</title>
    <link rel="stylesheet" href="css/index.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/header.css">
    <link rel="stylesheet" href="css/searchnav.css">
    <link rel="stylesheet" href="css/footer.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <script src="js/axios.js"></script>
    <script src="js/vue.js"></script>
</head>
<body>
<div id="app">

    <div class="container-fluid">
        <!-- 头部导航 -->
        <section id="header">
            <div class="header-box">
                <div class="address">
                    <select>
                        <option>成都市</option>
                        <option>绵阳市</option>
                        <option>上海市</option>
                        <option>深圳市</option>
                    </select>
                </div>
                <div class="nav">
                    <ul>
                        <li><a href="#">欢迎你，{{username}}</a></li>
                        <li><a href="register.html">注册 &ensp;/</a></li>
                        <li><a href="#">签到有礼 &ensp;/</a></li>
                        <li><a href="#">我的订单 &ensp;/</a></li>
                        <li><a href="#">我的特卖 &ensp;/</a></li>
                        <li><a href="#">会员俱乐部 &ensp;/</a></li>
                        <li><a href="#" @click="backlogin">退出登录&ensp; /</a></li>
                        <li><a href="#" data-toggle="modal" data-target="#myModal">修改密码</a></li>

                    </ul>
                </div>
            </div>
            <!-- 模态框 -->
            <div class="modal fade" id="myModal">
                <div class="modal-dialog">
                    <div class="modal-content">

                        <!-- 模态框头部 -->
                        <div class="modal-header">
                            <h4 class="modal-title">修改密码</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>

                        <!-- 模态框主体 -->
                        <div class="modal-body">
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">新密码</span>
                                </div>
                                <input type="password" v-model="password" class="form-control" placeholder="输入密码"
                                       id="usr" name="username">
                            </div>
                        </div>

                        <!-- 模态框底部 -->
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal" @click="update()">提交
                            </button>
                        </div>

                    </div>
                </div>
            </div>

        </section>
        <!-- 搜索框+导航栏 -->
        <section id="search-nav">
            <div class="search-nav-box">
                <div class="serach">
                    <div class="logo" style="flex: 1;">
                        <img src="img/logo.png" alt="">
                    </div>
                    <div class="adver" style="flex: 2;">
                        <img src="img/advertising.jpg"/>
                    </div>
                    <div calss="serach-border" style="flex: 2;">
                        <div class="serach-box">
                            <div>
                                <input type="text" v-model="searchtext" placeholder="6.16户外运动日">
                            </div>

                            <div class="btns" @click="search">
                                搜索
                            </div>
                        </div>
                    </div>
                    <div class="shop-cart" style="flex: 1;">
                        <div class="shop-cart-btn">
                            <a href="#">购物车</a>
                        </div>
                    </div>
                </div>
                <div class="navbars">
                    <div class="active">商品分类</div>
                    <div>推荐</div>
                    <div>3折疯抢</div>
                    <div>唯品快抢</div>
                    <div>唯品奥莱</div>
                    <div>女装</div>
                    <div>运动</div>
                    <div>鞋包</div>
                    <div>美妆</div>
                    <div>母婴</div>
                    <div>电器</div>
                    <div>男装</div>
                    <div>内衣</div>
                    <div>更多</div>
                </div>
            </div>

        </section>
        <hr style="margin: 5px;"/>
        <!-- 商品区域 -->
        <section id="goods">
            <div class="goods ">

                <div class="card" style="width:216px;height: 338px;" v-for="(item,index) in product" :key="index"
                     @click="todetail(item.id)">
                    <img class="card-img-top"
                         :src="item.picPath"
                         alt="Card image" style="width:100%">
                    <div class="card-body">
                        <h4 class="card-title" style="text-align: center;">￥{{item.price}}</h4>
                        <p class="shop-detail">{{item.info}}</p>
                    </div>


                </div>


            </div>


    </div>


    </section>

    <hr/>
    <div id="footer">
        <div class="login-footer" style="margin-top: 60px;">
            <div>
                <img style="display:block;margin: 0 auto;"
                     src="https://shop.vipstatic.com/img/common/footer_common_20200705-hash-2a8e96cf.png"
                     alt="">
            </div>
            <div style="display: flex; text-align: center; margin-top: 50px;">
                <div style="flex: 1;">
                    <p>服务保障</p>
                    <ul class="footer-text">
                        <li>正品保证</li>
                        <li>7天无理由放心退</li>
                        <li>7x15小时客户服务</li>
                        <li>7天无理由随心换</li>
                    </ul>
                </div>
                <div style="flex: 1;">
                    <p>服务保障</p>
                    <ul class="footer-text">
                        <li>正品保证</li>
                        <li>7天无理由放心退</li>
                        <li>7x15小时客户服务</li>
                        <li>7天无理由随心换</li>
                    </ul>
                </div>
                <div style="flex: 1;">
                    <p>服务保障</p>
                    <ul class="footer-text">
                        <li>正品保证</li>
                        <li>7天无理由放心退</li>
                        <li>7x15小时客户服务</li>
                        <li>7天无理由随心换</li>
                    </ul>
                </div>
                <div style="flex: 1;">
                    <p>服务保障</p>
                    <ul class="footer-text">
                        <li>正品保证</li>
                        <li>7天无理由放心退</li>
                        <li>7x15小时客户服务</li>
                        <li>7天无理由随心换</li>
                    </ul>
                </div>
                <div style="flex: 1;">
                    <p>服务保障</p>
                    <ul class="footer-text">
                        <li>正品保证</li>
                        <li>7天无理由放心退</li>
                        <li>7x15小时客户服务</li>
                        <li>7天无理由随心换</li>
                    </ul>
                </div>
                <div style="flex: 1;">
                    <p>服务保障</p>
                    <ul class="footer-text">
                        <li>正品保证</li>
                        <li>7天无理由放心退</li>
                        <li>7x15小时客户服务</li>
                        <li>7天无理由随心换</li>
                    </ul>
                </div>
            </div>
            <div class="txt" style="text-align: center; margin-top: 20px;">
                <p>Copyright © 2008-现在 vip.com，All Rights Reserved 使用本网站即表示接受 唯品会用户协议。版权所有 广州唯品会电子商务有限公司</p>
                <p>粤公网安备 44010302111111号 粤ICP备08114786号 增值业务经营许可证：粤B2-20170777 网络文化经营许可证：粤网文〔2021〕2056-282号
                </p>
                <p>经营主体证照 风险监测信息 互联网药品信息服务资格证书：（粤）-经营性-2018-0271 网络食品交易第三方平台备案凭证：粤B2-20170777
                    医疗器械网络交易服务第三方平台备案
                </p>
                <p>凭证：（粤）网械平台备字[2019]第00001号 出版物网络交易平台服务经营备案证：粤新出网备（2021）1号 未成年人关怀专区</p>
                <p>违法和不良信息举报电话：4006789888 算法推荐违规举报电话：4006789888</p>
            </div>

        </div>
    </div>
</div>

</div>
<script>
    const App = {
        data() {
            return {
                show: false,
                product: [],
                username: document.cookie.split("=")[1],
                password: "",
                searchtext: ""
            }
        },
        mounted() {
            axios({
                url: 'http://localhost:8080/shopping_war/show_products'
            }).then(res => {
                this.product = res.data
                console.log((this.product))
            })

        },
        methods: {
            search() {

              this.product  = this.product.filter(item => {
                   return  item.info.includes(this.searchtext)
                })

            },
            todetail(id) {
                console.log(id)
                axios({
                    url: `http://localhost:8080/shopping_war/show_product_detail?pid=${id}`
                }).then(res => {
                    console.log((res))
                })
                window.location.href = "http://localhost:8080/shopping_war/detail.html"
            },
            update() {
                console.log(this.password);
                axios({
                    url: 'http://localhost:8080/shopping_war/update',
                    method: 'post',
                    data: "password=" + this.password
                }).then(res => {
                    if (res.data == "success") {
                        alert("修改成功")
                        setTimeout(() => {
                            window.location.href = "http://localhost:8080/shopping_war/"
                        }, 2000)

                    }
                })
                this.password = ""
            },
            backlogin() {
                axios({
                    url: 'http://localhost:8080/shopping_war/back'
                }).then(res => {
                    if (res.data == "success") {
                        window.location.href = "http://localhost:8080/shopping_war/"
                    }
                })
            }
        },

    }
    Vue.createApp(App).mount('#app')
</script>
</body>
</html>
